package br.eck.stage;

import java.util.HashMap;

import org.newdawn.slick.SlickException;

import br.eck.config.Config;
import br.eck.formations.DiamondFormation;
import br.eck.formations.StairFormation;
import br.eck.model.base.enemys.TrexCrusader;
import br.eck.model.base.enemys.TrexFighter;
import br.eck.model.base.misc.Meteor;
import br.eck.stage.backgrounds.SimpleSpaceBackground;
import br.eck.stage.events.AddDestructableObjEvent;
import br.eck.stage.events.Event;
import br.eck.stage.events.ShowMessageEvent;

public class StageTest extends Stage {

    private TrexFighter enemy;
    private TrexCrusader enemy1;
    private Meteor meteor;

    @Override
    protected void initResources() throws SlickException {
        enemy = new TrexFighter(this);
        enemy1 = new TrexCrusader(this);
        meteor = new Meteor();
        setBackground(new SimpleSpaceBackground());
    }

    @Override
    protected void initEvents() throws SlickException {
        eventMap = new HashMap<Integer, Event>();

        DiamondFormation diamond = new DiamondFormation();
        StairFormation stair = new StairFormation();

        AddDestructableObjEvent e;

        ShowMessageEvent me = new ShowMessageEvent(this, "Approaching metor zone!", 2000);
        eventMap.put(3, me);

        e = new AddDestructableObjEvent(this, diamond.getFormation(meteor, 0, meteor.getImage().getHeight() * -3));
        eventMap.put(2, e);

        e = new AddDestructableObjEvent(this, stair.getFormation(meteor, 50, meteor.getImage().getHeight() * -4));
        eventMap.put(4, e);

        e = new AddDestructableObjEvent(this, stair.getFormation(meteor, 0, meteor.getImage().getHeight() * -4));
        eventMap.put(5, e);

        e = new AddDestructableObjEvent(this, stair.getFormation(meteor, 10, meteor.getImage().getHeight() * -4));
        eventMap.put(6, e);

        for (int i = 0; i <6; i++) {
            e = new AddDestructableObjEvent(this, diamond.getFormation(meteor, i * 90, meteor.getImage().getHeight() * -3));
            eventMap.put(7 + i + 2, e);
        }

        for (int i = 0; i <6; i++) {
            e = new AddDestructableObjEvent(this, diamond.getFormation(meteor, i * 90 - Config.PLAYABLE_AREA, meteor.getImage().getHeight() * -3));
            eventMap.put(15 + i + 2, e);
        }

        e = new AddDestructableObjEvent(this, stair.getFormation(meteor, 0, meteor.getImage().getHeight() * -3));
        eventMap.put(20, e);

        e = new AddDestructableObjEvent(this, diamond.getFormation(meteor, 200, meteor.getImage().getHeight() * -3));
        eventMap.put(25, e);

        e = new AddDestructableObjEvent(this, diamond.getFormation(meteor, 300, meteor.getImage().getHeight() * -3));
        eventMap.put(29, e);

        e = new AddDestructableObjEvent(this, diamond.getFormation(meteor, 600, meteor.getImage().getHeight() * -3));
        eventMap.put(31, e);

        for (int i = 0; i < 6; i++) {
            e = new AddDestructableObjEvent(this, diamond.getFormation(meteor, 100 * i, meteor.getImage().getHeight() * -3));
            eventMap.put(32 + i, e);
        }

        for (int i = 0; i < 6; i++) {
            e = new AddDestructableObjEvent(this, diamond.getFormation(meteor, 50 * i, meteor.getImage().getHeight() * -3));
            eventMap.put(40 + i, e);
        }

        for (int i = 0; i < 6; i++) {
            e = new AddDestructableObjEvent(this, diamond.getFormation(enemy, 50 * i, enemy.getImage().getHeight() * -3));
            eventMap.put(50 + i, e);
        }

        e = new AddDestructableObjEvent(this, stair.getFormation(enemy, 0, enemy.getImage().getHeight() * -3));
        eventMap.put(60, e);

        e = new AddDestructableObjEvent(this, diamond.getFormation(enemy, 200, enemy.getImage().getHeight() * -3));
        eventMap.put(65, e);

        e = new AddDestructableObjEvent(this, diamond.getFormation(enemy, 300, enemy.getImage().getHeight() * -3));
        eventMap.put(67, e);

        e = new AddDestructableObjEvent(this, diamond.getFormation(enemy, 600, enemy.getImage().getHeight() * -3));
        eventMap.put(70, e);

        e = new AddDestructableObjEvent(this, stair.getFormation(enemy1, 0, enemy1.getImage().getHeight() * -3));
        eventMap.put(75, e);

        e = new AddDestructableObjEvent(this, diamond.getFormation(enemy1, 200, enemy1.getImage().getHeight() * -3));
        eventMap.put(80, e);

        e = new AddDestructableObjEvent(this, diamond.getFormation(enemy1, 300, enemy1.getImage().getHeight() * -3));
        eventMap.put(82, e);

        e = new AddDestructableObjEvent(this, diamond.getFormation(enemy1, 600, enemy1.getImage().getHeight() * -3));
        eventMap.put(84, e);

    }
}
